/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author jackie
 */
@Entity
@Table(name = "user")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "User.findAll", query = "SELECT u FROM User u"),
    @NamedQuery(name = "User.findByUserEmail", query = "SELECT u FROM User u WHERE u.userEmail = :userEmail"),
    @NamedQuery(name = "User.findByUserPassword", query = "SELECT u FROM User u WHERE u.userPassword = :userPassword"),
    @NamedQuery(name = "User.findByName", query = "SELECT u FROM User u WHERE u.userFirstName LIKE :userFirstName"),
    @NamedQuery(name = "User.findByUserFirstName", query = "SELECT u FROM User u WHERE u.userFirstName = :userFirstName"),
    @NamedQuery(name = "User.findByUserLastName", query = "SELECT u FROM User u WHERE u.userLastName = :userLastName"),
    @NamedQuery(name = "User.findByUserJobTitile", query = "SELECT u FROM User u WHERE u.userJobTitile = :userJobTitile"),
    @NamedQuery(name = "User.findByUserCalendar", query = "SELECT u FROM User u WHERE u.userCalendar = :userCalendar"),
    @NamedQuery(name = "User.findByUserSuspended", query = "SELECT u FROM User u WHERE u.userSuspended = :userSuspended")})
public class User implements Serializable {
    @OneToMany(mappedBy = "userEmail")
    private Collection<Groups> groupsCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userEmail")
    private Collection<Invitee> inviteeCollection;
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "UserEmail")
    private String userEmail;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 255)
    @Column(name = "UserPassword")
    private String userPassword;
    @Size(max = 255)
    @Column(name = "UserFirstName")
    private String userFirstName;
    @Size(max = 255)
    @Column(name = "UserLastName")
    private String userLastName;
    @Size(max = 255)
    @Column(name = "UserJobTitile")
    private String userJobTitile;
    @Column(name = "UserCalendar")
    private Boolean userCalendar;
    @Column(name = "UserSuspended")
    private Boolean userSuspended;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "userEmail")
    private Collection<Event> eventCollection;

    public User() {
    }

    public User(String userEmail) {
        this.userEmail = userEmail;
    }

    public User(String userEmail, String userPassword) {
        this.userEmail = userEmail;
        this.userPassword = userPassword;
    }

    public String getUserEmail() {
        return userEmail;
    }

    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }

    public String getUserPassword() {
        return userPassword;
    }

    public void setUserPassword(String userPassword) {
        this.userPassword = userPassword;
    }

    public String getUserFirstName() {
        return userFirstName;
    }

    public void setUserFirstName(String userFirstName) {
        this.userFirstName = userFirstName;
    }

    public String getUserLastName() {
        return userLastName;
    }

    public void setUserLastName(String userLastName) {
        this.userLastName = userLastName;
    }

    public String getUserJobTitile() {
        return userJobTitile;
    }

    public void setUserJobTitile(String userJobTitile) {
        this.userJobTitile = userJobTitile;
    }

    public Boolean getUserCalendar() {
        return userCalendar;
    }

    public void setUserCalendar(Boolean userCalendar) {
        this.userCalendar = userCalendar;
    }

    public Boolean getUserSuspended() {
        return userSuspended;
    }

    public void setUserSuspended(Boolean userSuspended) {
        this.userSuspended = userSuspended;
    }

    @XmlTransient
    public Collection<Event> getEventCollection() {
        return eventCollection;
    }

    public void setEventCollection(Collection<Event> eventCollection) {
        this.eventCollection = eventCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (userEmail != null ? userEmail.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof User)) {
            return false;
        }
        User other = (User) object;
        if ((this.userEmail == null && other.userEmail != null) || (this.userEmail != null && !this.userEmail.equals(other.userEmail))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.entity.User[ userEmail=" + userEmail + " ]";
    }

    @XmlTransient
    public Collection<Invitee> getInviteeCollection() {
        return inviteeCollection;
    }

    public void setInviteeCollection(Collection<Invitee> inviteeCollection) {
        this.inviteeCollection = inviteeCollection;
    }

    @XmlTransient
    public Collection<Groups> getGroupsCollection() {
        return groupsCollection;
    }

    public void setGroupsCollection(Collection<Groups> groupsCollection) {
        this.groupsCollection = groupsCollection;
    }
    
}
